/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package mall;

import java.util.List;
import javax.faces.model.ListDataModel;
import mall.db.entities.Floor;
import org.primefaces.model.SelectableDataModel;

/**
 *
 * @author Iaroslav_Mazai
 */
public class FloorsDataModel extends ListDataModel<Floor> implements SelectableDataModel<Floor> {

	public FloorsDataModel(List<Floor> floors) {
		super(floors);
	}

	@Override
	public Object getRowKey(Floor t) {
		return t.getId();
	}

	@Override
	public Floor getRowData(String string) {
		List<Floor> floors = (List<Floor>) getWrappedData();

		for (Floor floor : floors) {
			if (floor.getId().equals(Integer.valueOf(string))) {
				return floor;
			}
		}

		return null;
	}
}
